﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.ConditionalAppearance;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp;

namespace DomainComponents.XCRM {
    [NonPersistent]
    public class CloseOpportunityParameters {
        public CloseOpportunityParameters(IOpportunity opportunity) {
            this.CloseDate = DateTime.Now;
            this.ActualRevenue = opportunity.Amount;
        }
        public OpportunityStatus Status { get; set; }
        public decimal ActualRevenue { get; set; }
        public DateTime CloseDate { get; set; }
    }

    [DomainLogic(typeof(IOpportunity))]
    public class OpportunityCloseLogic {
        public static void Close(IOpportunity opportunity, CloseOpportunityParameters parameters) {
            opportunity.Status = parameters.Status;
            opportunity.CloseDate = parameters.CloseDate;
            opportunity.ActualRevenue = parameters.ActualRevenue;
        }
    }
}
